import 'dart:convert';
import 'package:hi_common/hi_common.dart';
import 'package:json_annotation/json_annotation.dart';

import 'store_table.dart';

part 'order_detail_data.g.dart';

@JsonSerializable()
class OrderDetailData extends Object {
  @JsonKey(name: 'orderDetailList')
  List<OrderDetailList> orderDetailList;

  @JsonKey(name: 'orderProp')
  OrderProp orderProp;

  @JsonKey(name: 'payRecord')
  PayRecord payRecord;

  @JsonKey(name: 'sensitiveOperationList')
  List<SensitiveOperationList> sensitiveOperationList;

  @JsonKey(name: 'store')
  Store store;

  OrderDetailData(
    this.orderDetailList,
    this.orderProp,
    this.payRecord,
    this.sensitiveOperationList,
    this.store,
  );

  factory OrderDetailData.fromJson(Map<String, dynamic> srcJson) => _$OrderDetailDataFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderDetailDataToJson(this);
}

@JsonSerializable()
class OrderDetailList extends Object {
  @JsonKey(name: 'activityPrice')
  int activityPrice;

  @JsonKey(name: 'actualPrice')
  int actualPrice;

  @JsonKey(name: 'addTableId')
  int addTableId;

  @JsonKey(name: 'backReason')
  String backReason;

  @JsonKey(name: 'cancelDiscount')
  int cancelDiscount;

  @JsonKey(name: 'comRate')
  String comRate;

  @JsonKey(name: 'commodityId')
  int commodityId;

  @JsonKey(name: 'commodityPrice')
  int commodityPrice;

  @JsonKey(name: 'commodityType')
  int commodityType;

  @JsonKey(name: 'ctime')
  String ctime;

  @JsonKey(name: 'discountId')
  int discountId;

  @JsonKey(name: 'discountName')
  String discountName;

  @JsonKey(name: 'discountRate')
  int discountRate;

  @JsonKey(name: 'discountReason')
  String discountReason;

  @JsonKey(name: 'discountType')
  int discountType;

  @JsonKey(name: 'headImage')
  String headImage;

  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'image')
  String image;

  @JsonKey(name: 'isBack')
  int isBack;

  @JsonKey(name: 'laterServer')
  int laterServer;

  @JsonKey(name: 'mainCashDeviceStatus')
  int mainCashDeviceStatus;

  @JsonKey(name: 'menuId')
  int menuId;

  @JsonKey(name: 'menuName')
  String menuName;

  @JsonKey(name: 'meterialId')
  String meterialId;

  @JsonKey(name: 'meterialOrderDetailList')
  List<MeterialOrderDetailList> meterialOrderDetailList;

  @JsonKey(name: 'meterialPriceDTOList')
  List<MeterialPriceDTOList> meterialPriceDTOList;

  @JsonKey(name: 'nickname')
  String nickname;

  @JsonKey(name: 'num')
  int num;

  @JsonKey(name: 'orderDetailMeterialList')
  List<OrderDetailMeterialList> orderDetailMeterialList;

  String get materialText {
    if (orderDetailMeterialList == null || orderDetailMeterialList.length == 0) {
      return null;
    }

    List<String> temp = [];
    for (final item in orderDetailMeterialList) {
      temp.add('${item.meterialName}*${item.meterialNum}');
    }

    return '加料：' + temp.join('，');
  }

  @JsonKey(name: 'orderDetailTasteList')
  List<OrderDetailTasteList> orderDetailTasteList;

  String get tasteText {
    if (orderDetailTasteList == null || orderDetailTasteList.length == 0) {
      return null;
    }

    Map<String, List<String>> tasteMap = {};
    for (final item in orderDetailTasteList) {
      if (tasteMap.containsKey(item.tasteName)) {
        tasteMap[item.tasteName].add(item.tasteLabel);
      } else {
        tasteMap[item.tasteName] = [item.tasteLabel];
      }
    }

    String temp = '';

    tasteMap.forEach((key, value) {
      temp += key + '：';
      temp += value.join('，');
    });

    return temp;
  }

  @JsonKey(name: 'orderId')
  String orderId;

  @JsonKey(name: 'payPrice')
  int payPrice;

  @JsonKey(name: 'payStatus')
  int payStatus;

  @JsonKey(name: 'porderId')
  int porderId;

  @JsonKey(name: 'price')
  int price;

  @JsonKey(name: 'remark')
  String remark;

  @JsonKey(name: 'secondDiscountCount')
  int secondDiscountCount;

  @JsonKey(name: 'secondType')
  int secondType;

  @JsonKey(name: 'skuId')
  int skuId;

  @JsonKey(name: 'specDefText')
  String specDefText;

  @JsonKey(name: 'specText')
  String specText;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'storeName')
  String storeName;

  @JsonKey(name: 'tableId')
  int tableId;

  @JsonKey(name: 'tableName')
  String tableName;

  @JsonKey(name: 'tasteLabel')
  String tasteLabel;

  @JsonKey(name: 'tasteOrderDetailList')
  List<TasteOrderDetailList> tasteOrderDetailList;

  @JsonKey(name: 'title')
  String title;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  @JsonKey(name: 'userId')
  int userId;

  @JsonKey(name: 'userType')
  int userType;

  @JsonKey(name: 'waiterHeadImage')
  String waiterHeadImage;

  @JsonKey(name: 'waiterId')
  int waiterId;

  @JsonKey(name: 'waiterName')
  String waiterName;

  OrderDetailList(
    this.activityPrice,
    this.actualPrice,
    this.addTableId,
    this.backReason,
    this.cancelDiscount,
    this.comRate,
    this.commodityId,
    this.commodityPrice,
    this.commodityType,
    this.ctime,
    this.discountId,
    this.discountName,
    this.discountRate,
    this.discountReason,
    this.discountType,
    this.headImage,
    this.id,
    this.image,
    this.isBack,
    this.laterServer,
    this.mainCashDeviceStatus,
    this.menuId,
    this.menuName,
    this.meterialId,
    this.meterialOrderDetailList,
    this.meterialPriceDTOList,
    this.nickname,
    this.num,
    this.orderDetailMeterialList,
    this.orderDetailTasteList,
    this.orderId,
    this.payPrice,
    this.payStatus,
    this.porderId,
    this.price,
    this.remark,
    this.secondDiscountCount,
    this.secondType,
    this.skuId,
    this.specDefText,
    this.specText,
    this.storeId,
    this.storeName,
    this.tableId,
    this.tableName,
    this.tasteLabel,
    this.tasteOrderDetailList,
    this.title,
    this.unionOrderId,
    this.userId,
    this.userType,
    this.waiterHeadImage,
    this.waiterId,
    this.waiterName,
  );

  factory OrderDetailList.fromJson(Map<String, dynamic> srcJson) => _$OrderDetailListFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderDetailListToJson(this);
}

@JsonSerializable()
class MeterialOrderDetailList extends Object {
  @JsonKey(name: 'commodityId')
  int commodityId;

  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'meterialId')
  int meterialId;

  @JsonKey(name: 'meterialName')
  String meterialName;

  @JsonKey(name: 'meterialNum')
  int meterialNum;

  @JsonKey(name: 'meterialNumUnit')
  int meterialNumUnit;

  @JsonKey(name: 'meterialPrice')
  int meterialPrice;

  @JsonKey(name: 'orderDetailId')
  int orderDetailId;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  MeterialOrderDetailList(
    this.commodityId,
    this.id,
    this.meterialId,
    this.meterialName,
    this.meterialNum,
    this.meterialNumUnit,
    this.meterialPrice,
    this.orderDetailId,
    this.storeId,
    this.unionOrderId,
  );

  factory MeterialOrderDetailList.fromJson(Map<String, dynamic> srcJson) => _$MeterialOrderDetailListFromJson(srcJson);

  Map<String, dynamic> toJson() => _$MeterialOrderDetailListToJson(this);
}

@JsonSerializable()
class MeterialPriceDTOList extends Object {
  @JsonKey(name: 'activityPrice')
  int activityPrice;

  @JsonKey(name: 'meterialNum')
  int meterialNum;

  @JsonKey(name: 'meterialNumUnit')
  int meterialNumUnit;

  @JsonKey(name: 'price')
  int price;

  MeterialPriceDTOList(
    this.activityPrice,
    this.meterialNum,
    this.meterialNumUnit,
    this.price,
  );

  factory MeterialPriceDTOList.fromJson(Map<String, dynamic> srcJson) => _$MeterialPriceDTOListFromJson(srcJson);

  Map<String, dynamic> toJson() => _$MeterialPriceDTOListToJson(this);
}

@JsonSerializable()
class OrderDetailMeterialList extends Object {
  @JsonKey(name: 'commodityId')
  int commodityId;

  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'meterialId')
  int meterialId;

  @JsonKey(name: 'meterialName')
  String meterialName;

  @JsonKey(name: 'meterialNum')
  int meterialNum;

  @JsonKey(name: 'meterialNumUnit')
  int meterialNumUnit;

  @JsonKey(name: 'meterialPrice')
  int meterialPrice;

  @JsonKey(name: 'orderDetailId')
  int orderDetailId;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  OrderDetailMeterialList(
    this.commodityId,
    this.id,
    this.meterialId,
    this.meterialName,
    this.meterialNum,
    this.meterialNumUnit,
    this.meterialPrice,
    this.orderDetailId,
    this.storeId,
    this.unionOrderId,
  );

  factory OrderDetailMeterialList.fromJson(Map<String, dynamic> srcJson) => _$OrderDetailMeterialListFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderDetailMeterialListToJson(this);
}

@JsonSerializable()
class OrderDetailTasteList extends Object {
  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'orderDetailId')
  int orderDetailId;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'tasteId')
  int tasteId;

  @JsonKey(name: 'tasteLabel')
  String tasteLabel;

  @JsonKey(name: 'tasteName')
  String tasteName;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  OrderDetailTasteList(
    this.id,
    this.orderDetailId,
    this.storeId,
    this.tasteId,
    this.tasteLabel,
    this.tasteName,
    this.unionOrderId,
  );

  factory OrderDetailTasteList.fromJson(Map<String, dynamic> srcJson) => _$OrderDetailTasteListFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderDetailTasteListToJson(this);
}

@JsonSerializable()
class TasteOrderDetailList extends Object {
  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'orderDetailId')
  int orderDetailId;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'tasteId')
  int tasteId;

  @JsonKey(name: 'tasteLabel')
  String tasteLabel;

  @JsonKey(name: 'tasteName')
  String tasteName;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  TasteOrderDetailList(
    this.id,
    this.orderDetailId,
    this.storeId,
    this.tasteId,
    this.tasteLabel,
    this.tasteName,
    this.unionOrderId,
  );

  factory TasteOrderDetailList.fromJson(Map<String, dynamic> srcJson) => _$TasteOrderDetailListFromJson(srcJson);

  Map<String, dynamic> toJson() => _$TasteOrderDetailListToJson(this);
}

@JsonSerializable()
class OrderProp extends Object {
  @JsonKey(name: 'addTableId')
  int addTableId;

  @JsonKey(name: 'billStatus')
  int billStatus;

  @JsonKey(name: 'buyerIsRate')
  int buyerIsRate;

  @JsonKey(name: 'buyerMessage')
  String buyerMessage;

  @JsonKey(name: 'cancelReason')
  String cancelReason;

  @JsonKey(name: 'casherId')
  int casherId;

  @JsonKey(name: 'cashierName')
  String cashierName;

  @JsonKey(name: 'channelName')
  String channelName;

  @JsonKey(name: 'chargeMoney')
  int chargeMoney;

  @JsonKey(name: 'commodityDiscountDetail')
  String commodityDiscountDetail;

  @JsonKey(name: 'commodityDiscountFee')
  int commodityDiscountFee;

  @JsonKey(name: 'completeId')
  int completeId;

  @JsonKey(name: 'couponFee')
  int couponFee;

  @JsonKey(name: 'couponRemark')
  String couponRemark;

  @JsonKey(name: 'customDiscountRate')
  int customDiscountRate;

  @JsonKey(name: 'customDiscountReason')
  String customDiscountReason;

  @JsonKey(name: 'decreaseAmount')
  int decreaseAmount;

  @JsonKey(name: 'discountId')
  int discountId;

  @JsonKey(name: 'essential')
  String essential;

  @JsonKey(name: 'freeDiscountAmount')
  int freeDiscountAmount;

  @JsonKey(name: 'freeReason')
  String freeReason;

  @JsonKey(name: 'guests')
  int guests;

  @JsonKey(name: 'invoiceType')
  int invoiceType;

  @JsonKey(name: 'isComplete')
  int isComplete;

  @JsonKey(name: 'lockTableTime')
  String lockTableTime;

  @JsonKey(name: 'nickname')
  String nickname;

  @JsonKey(name: 'openTableMan')
  String openTableMan;

  @JsonKey(name: 'openid')
  String openid;

  @JsonKey(name: 'oppositeOrderCount')
  int oppositeOrderCount;

  @JsonKey(name: 'oppositeOrderTime')
  String oppositeOrderTime;

  @JsonKey(name: 'oppsiteOrderReason')
  String oppsiteOrderReason;

  @JsonKey(name: 'placeOrderMan')
  String placeOrderMan;

  @JsonKey(name: 'order')
  List<Order> order;

  @JsonKey(name: 'orderDetail')
  List<OrderDetail> orderDetail;

  @JsonKey(name: 'orderDeviceId')
  int orderDeviceId;

  @JsonKey(name: 'orderDiscountDetail')
  String orderDiscountDetail;

  @JsonKey(name: 'orderDiscountFee')
  int orderDiscountFee;

  @JsonKey(name: 'orderDiscountType')
  int orderDiscountType;

  String memberDiscountDetail;

  int memberDiscountAmount;

  List<String> get orderDiscountText {
    final commodityDiscounts = (jsonDecode(commodityDiscountDetail ?? '[]')) as List;
    final orderDiscounts = (jsonDecode(orderDiscountDetail ?? '[]')) as List;
    final memberDiscounts = (jsonDecode(memberDiscountDetail ?? '[]')) as List;

    if (commodityDiscounts.length == 0 && orderDiscounts.length == 0 && memberDiscounts.length == 0) {
      return ['无折扣'];
    }

    List<String> discounts = [];
    for (final commodityDiscount in commodityDiscounts) {
      discounts.add('${commodityDiscount['discountName']}(-${AmountUtil.price2String(commodityDiscount['discountAmount'])})');
    }
    for (final orderDiscount in orderDiscounts) {
      discounts.add('${orderDiscount['discountName']}(-${AmountUtil.price2String(orderDiscount['discountAmount'])})');
    }
    for (final memberDiscount in memberDiscounts) {
      discounts.add('${memberDiscount['discountName']}');
    }

    return discounts;
  }

  @JsonKey(name: 'orderPayTypeList')
  List<OrderPayTypeList> orderPayTypeList;

  @JsonKey(name: 'orderQrcode')
  String orderQrcode;

  @JsonKey(name: 'orderSource')
  int orderSource;

  @JsonKey(name: 'orderStatus')
  int orderStatus;

  String get orderStatusText {
    //订单状态，0：新建，1：已撤单，2：未结账，3：已结账，4：已删除，5：已退单
    Map<int, String> map = {
      0: '新建',
      1: '已撤单',
      2: '未结账',
      3: '已结账',
      4: '已删除',
      5: '已退单',
    };

    return map[orderStatus] ?? '--';
  }

  @JsonKey(name: 'orderType')
  int orderType;

  @JsonKey(name: 'payDeviceId')
  int payDeviceId;

  @JsonKey(name: 'payOrderId')
  String payOrderId;

  @JsonKey(name: 'payOrderTime')
  String payOrderTime;

  @JsonKey(name: 'payRecord')
  PayRecord payRecord;

  @JsonKey(name: 'payStatus')
  int payStatus;

  @JsonKey(name: 'payTime')
  String payTime;

  @JsonKey(name: 'receiveAmount')
  int receiveAmount;

  @JsonKey(name: 'remark')
  String remark;

  @JsonKey(name: 'storeDiscountAmount')
  int storeDiscountAmount;

  @JsonKey(name: 'storeHeadImage')
  String storeHeadImage;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'storeName')
  String storeName;

  @JsonKey(name: 'storeNo')
  String storeNo;

  @JsonKey(name: 'storeTable')
  StoreTable storeTable;

  @JsonKey(name: 'sysDecreaseAmount')
  int sysDecreaseAmount;

  @JsonKey(name: 'sysUser')
  SysUser sysUser;

  @JsonKey(name: 'tableId')
  int tableId;

  @JsonKey(name: 'tableName')
  String tableName;

  @JsonKey(name: 'tip')
  int tip;

  @JsonKey(name: 'totalFee')
  int totalFee;

  @JsonKey(name: 'totalPrice')
  int totalPrice;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  @JsonKey(name: 'user')
  User user;

  @JsonKey(name: 'userId')
  int userId;

  @JsonKey(name: 'waiterHeadImage')
  String waiterHeadImage;

  @JsonKey(name: 'waiterId')
  int waiterId;

  @JsonKey(name: 'waiterName')
  String waiterName;

  @JsonKey(name: 'waiterOpenid')
  String waiterOpenid;

  @JsonKey(name: 'waiterRate')
  String waiterRate;

  @JsonKey(name: 'waiterRateDesc')
  String waiterRateDesc;

  @JsonKey(name: 'withDrawAmount')
  int withDrawAmount;

  @JsonKey(name: 'withDrawReason')
  String withDrawReason;

  @JsonKey(name: 'withDrawTime')
  String withDrawTime;

  List<OrderSurcharge> listOrderSurcharge;

  String get surchargeText {
    if (listOrderSurcharge == null || listOrderSurcharge.length == 0) {
      return '无附加费';
    }
    var sb = StringBuffer();
    for (var value in listOrderSurcharge) {
      sb.write('${value.surchargeName}(${AmountUtil.price2String(value.surchargeAmount)})');
    }

    return sb.toString();
  }

  String get orderPersionName {
    return waiterName ?? sysUser.realname ?? '--';
  }

  String get payTypeName {
    var temp = '';
    orderPayTypeList?.forEach((item) {
      temp += item.payTypeName;

      if (item != orderPayTypeList.last) {
        temp += '、';
      }
    });

    return temp;
  }

  OrderProp(
    this.addTableId,
    this.billStatus,
    this.buyerIsRate,
    this.buyerMessage,
    this.cancelReason,
    this.casherId,
    this.cashierName,
    this.channelName,
    this.chargeMoney,
    this.commodityDiscountDetail,
    this.commodityDiscountFee,
    this.completeId,
    this.couponFee,
    this.couponRemark,
    this.customDiscountRate,
    this.customDiscountReason,
    this.decreaseAmount,
    this.discountId,
    this.essential,
    this.freeDiscountAmount,
    this.freeReason,
    this.guests,
    this.invoiceType,
    this.isComplete,
    this.lockTableTime,
    this.nickname,
    this.openTableMan,
    this.openid,
    this.oppositeOrderCount,
    this.oppositeOrderTime,
    this.oppsiteOrderReason,
    this.placeOrderMan,
    this.order,
    this.orderDetail,
    this.orderDeviceId,
    this.orderDiscountDetail,
    this.orderDiscountFee,
    this.orderDiscountType,
    this.orderPayTypeList,
    this.orderQrcode,
    this.orderSource,
    this.orderStatus,
    this.orderType,
    this.payDeviceId,
    this.payOrderId,
    this.payOrderTime,
    this.payRecord,
    this.payStatus,
    this.payTime,
    this.receiveAmount,
    this.remark,
    this.storeDiscountAmount,
    this.storeHeadImage,
    this.storeId,
    this.storeName,
    this.storeNo,
    this.storeTable,
    this.sysDecreaseAmount,
    this.sysUser,
    this.tableId,
    this.tableName,
    this.tip,
    this.totalFee,
    this.totalPrice,
    this.unionOrderId,
    this.user,
    this.userId,
    this.waiterHeadImage,
    this.waiterId,
    this.waiterName,
    this.waiterOpenid,
    this.waiterRate,
    this.waiterRateDesc,
    this.withDrawAmount,
    this.withDrawReason,
    this.withDrawTime,
  );

  factory OrderProp.fromJson(Map<String, dynamic> srcJson) => _$OrderPropFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderPropToJson(this);
}

@JsonSerializable()
class Order extends Object {
  @JsonKey(name: 'actualPrice')
  int actualPrice;

  @JsonKey(name: 'addTableId')
  int addTableId;

  @JsonKey(name: 'buyerIsRate')
  int buyerIsRate;

  @JsonKey(name: 'closeTime')
  String closeTime;

  @JsonKey(name: 'ctime')
  String ctime;

  @JsonKey(name: 'h5QrCode')
  String h5QrCode;

  @JsonKey(name: 'mainCashDeviceStatus')
  int mainCashDeviceStatus;

  @JsonKey(name: 'nickname')
  String nickname;

  @JsonKey(name: 'orderDetail')
  List<OrderDetail> orderDetail;

  @JsonKey(name: 'orderId')
  String orderId;

  @JsonKey(name: 'orderStatus')
  int orderStatus;

  @JsonKey(name: 'payStatus')
  int payStatus;

  @JsonKey(name: 'payTime')
  String payTime;

  @JsonKey(name: 'payType')
  int payType;

  @JsonKey(name: 'refundTime')
  String refundTime;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'storeName')
  String storeName;

  @JsonKey(name: 'tableId')
  int tableId;

  @JsonKey(name: 'tableName')
  String tableName;

  @JsonKey(name: 'totalFee')
  int totalFee;

  @JsonKey(name: 'totalPrice')
  int totalPrice;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  @JsonKey(name: 'userId')
  int userId;

  @JsonKey(name: 'waiterHeadImage')
  String waiterHeadImage;

  @JsonKey(name: 'waiterId')
  int waiterId;

  @JsonKey(name: 'waiterName')
  String waiterName;

  Order(
    this.actualPrice,
    this.addTableId,
    this.buyerIsRate,
    this.closeTime,
    this.ctime,
    this.h5QrCode,
    this.mainCashDeviceStatus,
    this.nickname,
    this.orderDetail,
    this.orderId,
    this.orderStatus,
    this.payStatus,
    this.payTime,
    this.payType,
    this.refundTime,
    this.storeId,
    this.storeName,
    this.tableId,
    this.tableName,
    this.totalFee,
    this.totalPrice,
    this.unionOrderId,
    this.userId,
    this.waiterHeadImage,
    this.waiterId,
    this.waiterName,
  );

  factory Order.fromJson(Map<String, dynamic> srcJson) => _$OrderFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderToJson(this);
}

@JsonSerializable()
class OrderDetail extends Object {
  @JsonKey(name: 'activityPrice')
  int activityPrice;

  @JsonKey(name: 'actualPrice')
  int actualPrice;

  @JsonKey(name: 'addTableId')
  int addTableId;

  @JsonKey(name: 'backReason')
  String backReason;

  @JsonKey(name: 'cancelDiscount')
  int cancelDiscount;

  @JsonKey(name: 'comRate')
  String comRate;

  @JsonKey(name: 'commodityId')
  int commodityId;

  @JsonKey(name: 'commodityPrice')
  int commodityPrice;

  @JsonKey(name: 'commodityType')
  int commodityType;

  @JsonKey(name: 'ctime')
  String ctime;

  @JsonKey(name: 'discountId')
  int discountId;

  @JsonKey(name: 'discountName')
  String discountName;

  @JsonKey(name: 'discountRate')
  int discountRate;

  @JsonKey(name: 'discountReason')
  String discountReason;

  @JsonKey(name: 'discountType')
  int discountType;

  @JsonKey(name: 'headImage')
  String headImage;

  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'image')
  String image;

  @JsonKey(name: 'isBack')
  int isBack;

  @JsonKey(name: 'laterServer')
  int laterServer;

  @JsonKey(name: 'mainCashDeviceStatus')
  int mainCashDeviceStatus;

  @JsonKey(name: 'menuId')
  int menuId;

  @JsonKey(name: 'menuName')
  String menuName;

  @JsonKey(name: 'meterialId')
  String meterialId;

  @JsonKey(name: 'meterialOrderDetailList')
  List<MeterialOrderDetailList> meterialOrderDetailList;

  @JsonKey(name: 'meterialPriceDTOList')
  List<MeterialPriceDTOList> meterialPriceDTOList;

  @JsonKey(name: 'nickname')
  String nickname;

  @JsonKey(name: 'num')
  int num;

  @JsonKey(name: 'orderDetailMeterialList')
  List<OrderDetailMeterialList> orderDetailMeterialList;

  @JsonKey(name: 'orderDetailTasteList')
  List<OrderDetailTasteList> orderDetailTasteList;

  @JsonKey(name: 'orderId')
  String orderId;

  @JsonKey(name: 'payPrice')
  int payPrice;

  @JsonKey(name: 'payStatus')
  int payStatus;

  @JsonKey(name: 'porderId')
  int porderId;

  @JsonKey(name: 'price')
  int price;

  @JsonKey(name: 'remark')
  String remark;

  @JsonKey(name: 'secondDiscountCount')
  int secondDiscountCount;

  @JsonKey(name: 'secondType')
  int secondType;

  @JsonKey(name: 'skuId')
  int skuId;

  @JsonKey(name: 'specDefText')
  String specDefText;

  @JsonKey(name: 'specText')
  String specText;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'storeName')
  String storeName;

  @JsonKey(name: 'tableId')
  int tableId;

  @JsonKey(name: 'tableName')
  String tableName;

  @JsonKey(name: 'tasteLabel')
  String tasteLabel;

  @JsonKey(name: 'tasteOrderDetailList')
  List<TasteOrderDetailList> tasteOrderDetailList;

  @JsonKey(name: 'title')
  String title;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  @JsonKey(name: 'userId')
  int userId;

  @JsonKey(name: 'userType')
  int userType;

  @JsonKey(name: 'waiterHeadImage')
  String waiterHeadImage;

  @JsonKey(name: 'waiterId')
  int waiterId;

  @JsonKey(name: 'waiterName')
  String waiterName;

  OrderDetail(
    this.activityPrice,
    this.actualPrice,
    this.addTableId,
    this.backReason,
    this.cancelDiscount,
    this.comRate,
    this.commodityId,
    this.commodityPrice,
    this.commodityType,
    this.ctime,
    this.discountId,
    this.discountName,
    this.discountRate,
    this.discountReason,
    this.discountType,
    this.headImage,
    this.id,
    this.image,
    this.isBack,
    this.laterServer,
    this.mainCashDeviceStatus,
    this.menuId,
    this.menuName,
    this.meterialId,
    this.meterialOrderDetailList,
    this.meterialPriceDTOList,
    this.nickname,
    this.num,
    this.orderDetailMeterialList,
    this.orderDetailTasteList,
    this.orderId,
    this.payPrice,
    this.payStatus,
    this.porderId,
    this.price,
    this.remark,
    this.secondDiscountCount,
    this.secondType,
    this.skuId,
    this.specDefText,
    this.specText,
    this.storeId,
    this.storeName,
    this.tableId,
    this.tableName,
    this.tasteLabel,
    this.tasteOrderDetailList,
    this.title,
    this.unionOrderId,
    this.userId,
    this.userType,
    this.waiterHeadImage,
    this.waiterId,
    this.waiterName,
  );

  factory OrderDetail.fromJson(Map<String, dynamic> srcJson) => _$OrderDetailFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderDetailToJson(this);
}

@JsonSerializable()
class OrderDiscountDetailArray extends Object {
  OrderDiscountDetailArray();

  factory OrderDiscountDetailArray.fromJson(Map<String, dynamic> srcJson) => _$OrderDiscountDetailArrayFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderDiscountDetailArrayToJson(this);
}

@JsonSerializable()
class OrderPayTypeList extends Object {
  @JsonKey(name: 'actualMoney')
  int actualMoney;

  @JsonKey(name: 'chargeMoney')
  int chargeMoney;

  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'payCount')
  int payCount;

  @JsonKey(name: 'payTime')
  String payTime;

  @JsonKey(name: 'payType')
  int payType;

  @JsonKey(name: 'payTypeName')
  String payTypeName;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'totalFee')
  int totalFee;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  OrderPayTypeList(
    this.actualMoney,
    this.chargeMoney,
    this.id,
    this.payCount,
    this.payTime,
    this.payType,
    this.payTypeName,
    this.storeId,
    this.totalFee,
    this.unionOrderId,
  );

  factory OrderPayTypeList.fromJson(Map<String, dynamic> srcJson) => _$OrderPayTypeListFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderPayTypeListToJson(this);
}

@JsonSerializable()
class PayRecord extends Object {
  @JsonKey(name: 'billStatus')
  int billStatus;

  @JsonKey(name: 'channelId')
  String channelId;

  @JsonKey(name: 'channelName')
  String channelName;

  @JsonKey(name: 'channelOrderNo')
  String channelOrderNo;

  @JsonKey(name: 'completeId')
  int completeId;

  @JsonKey(name: 'mchId')
  String mchId;

  @JsonKey(name: 'mchInfoId')
  int mchInfoId;

  @JsonKey(name: 'mchRefundNo')
  String mchRefundNo;

  @JsonKey(name: 'nickname')
  String nickname;

  @JsonKey(name: 'openid')
  String openid;

  @JsonKey(name: 'orderTime')
  String orderTime;

  @JsonKey(name: 'payDeviceId')
  int payDeviceId;

  @JsonKey(name: 'payOrderId')
  String payOrderId;

  @JsonKey(name: 'payStatus')
  int payStatus;

  @JsonKey(name: 'payTime')
  String payTime;

  @JsonKey(name: 'payType')
  int payType;

  @JsonKey(name: 'payTypeVO')
  PayTypeVO payTypeVO;

  @JsonKey(name: 'recordId')
  String recordId;

  @JsonKey(name: 'recordType')
  int recordType;

  @JsonKey(name: 'refundTime')
  String refundTime;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'storeName')
  String storeName;

  @JsonKey(name: 'storeNo')
  String storeNo;

  @JsonKey(name: 'sysUser')
  SysUser sysUser;

  @JsonKey(name: 'tableId')
  int tableId;

  @JsonKey(name: 'tableName')
  String tableName;

  @JsonKey(name: 'tip')
  int tip;

  @JsonKey(name: 'totalFee')
  int totalFee;

  @JsonKey(name: 'unionOrderId')
  String unionOrderId;

  @JsonKey(name: 'userId')
  int userId;

  @JsonKey(name: 'waiterId')
  int waiterId;

  @JsonKey(name: 'waiterOpenid')
  String waiterOpenid;

  PayRecord(
    this.billStatus,
    this.channelId,
    this.channelName,
    this.channelOrderNo,
    this.completeId,
    this.mchId,
    this.mchInfoId,
    this.mchRefundNo,
    this.nickname,
    this.openid,
    this.orderTime,
    this.payDeviceId,
    this.payOrderId,
    this.payStatus,
    this.payTime,
    this.payType,
    this.payTypeVO,
    this.recordId,
    this.recordType,
    this.refundTime,
    this.storeId,
    this.storeName,
    this.storeNo,
    this.sysUser,
    this.tableId,
    this.tableName,
    this.tip,
    this.totalFee,
    this.unionOrderId,
    this.userId,
    this.waiterId,
    this.waiterOpenid,
  );

  factory PayRecord.fromJson(Map<String, dynamic> srcJson) => _$PayRecordFromJson(srcJson);

  Map<String, dynamic> toJson() => _$PayRecordToJson(this);
}

@JsonSerializable()
class PayTypeVO extends Object {
  @JsonKey(name: 'name')
  String name;

  @JsonKey(name: 'type')
  int type;

  @JsonKey(name: 'typeName')
  String typeName;

  PayTypeVO(
    this.name,
    this.type,
    this.typeName,
  );

  factory PayTypeVO.fromJson(Map<String, dynamic> srcJson) => _$PayTypeVOFromJson(srcJson);

  Map<String, dynamic> toJson() => _$PayTypeVOToJson(this);
}

@JsonSerializable()
class SysUser extends Object {
  @JsonKey(name: 'authCacheKey')
  int authCacheKey;

  @JsonKey(name: 'createTime')
  String createTime;

  @JsonKey(name: 'deptId')
  int deptId;

  @JsonKey(name: 'email')
  String email;

  @JsonKey(name: 'first')
  int first;

  @JsonKey(name: 'gender')
  int gender;

  @JsonKey(name: 'headImage')
  String headImage;

  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'idCard')
  String idCard;

  @JsonKey(name: 'isFulltimeJob')
  int isFulltimeJob;

  @JsonKey(name: 'nickname')
  String nickname;

  @JsonKey(name: 'openid')
  String openid;

  @JsonKey(name: 'phone')
  String phone;

  @JsonKey(name: 'realname')
  String realname;

  @JsonKey(name: 'roles')
  List<dynamic> roles;

  @JsonKey(name: 'status')
  int status;

  @JsonKey(name: 'storeNo')
  String storeNo;

  @JsonKey(name: 'token')
  String token;

  @JsonKey(name: 'type')
  int type;

  @JsonKey(name: 'userId')
  int userId;

  @JsonKey(name: 'username')
  String username;

  @JsonKey(name: 'weixinId')
  String weixinId;

  @JsonKey(name: 'wxHeadImage')
  String wxHeadImage;

  SysUser(
    this.authCacheKey,
    this.createTime,
    this.deptId,
    this.email,
    this.first,
    this.gender,
    this.headImage,
    this.id,
    this.idCard,
    this.isFulltimeJob,
    this.nickname,
    this.openid,
    this.phone,
    this.realname,
    this.roles,
    this.status,
    this.storeNo,
    this.token,
    this.type,
    this.userId,
    this.username,
    this.weixinId,
    this.wxHeadImage,
  );

  factory SysUser.fromJson(Map<String, dynamic> srcJson) => _$SysUserFromJson(srcJson);

  Map<String, dynamic> toJson() => _$SysUserToJson(this);
}

@JsonSerializable()
class User extends Object {
  @JsonKey(name: 'ctime')
  String ctime;

  @JsonKey(name: 'headImage')
  String headImage;

  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'level')
  int level;

  @JsonKey(name: 'nickname')
  String nickname;

  @JsonKey(name: 'openid')
  String openid;

  @JsonKey(name: 'phone')
  String phone;

  @JsonKey(name: 'token')
  String token;

  @JsonKey(name: 'unionid')
  String unionid;

  @JsonKey(name: 'username')
  String username;

  @JsonKey(name: 'utime')
  String utime;

  User(
    this.ctime,
    this.headImage,
    this.id,
    this.level,
    this.nickname,
    this.openid,
    this.phone,
    this.token,
    this.unionid,
    this.username,
    this.utime,
  );

  factory User.fromJson(Map<String, dynamic> srcJson) => _$UserFromJson(srcJson);

  Map<String, dynamic> toJson() => _$UserToJson(this);
}

@JsonSerializable()
class SensitiveOperationList extends Object {
  @JsonKey(name: 'operationName')
  String operationName;

  @JsonKey(name: 'operationTime')
  String operationTime;

  @JsonKey(name: 'operationType')
  int operationType;

  @JsonKey(name: 'reason')
  String reason;

  @JsonKey(name: 'userName')
  String userName;

  SensitiveOperationList(
    this.operationName,
    this.operationTime,
    this.operationType,
    this.reason,
    this.userName,
  );

  factory SensitiveOperationList.fromJson(Map<String, dynamic> srcJson) => _$SensitiveOperationListFromJson(srcJson);

  Map<String, dynamic> toJson() => _$SensitiveOperationListToJson(this);
}

@JsonSerializable()
class Store extends Object {
  @JsonKey(name: 'addressDetail')
  String addressDetail;

  @JsonKey(name: 'city')
  String city;

  @JsonKey(name: 'cityCode')
  String cityCode;

  @JsonKey(name: 'closeTime')
  String closeTime;

  @JsonKey(name: 'ctime')
  String ctime;

  @JsonKey(name: 'dayBissinessTarget')
  int dayBissinessTarget;

  @JsonKey(name: 'district')
  String district;

  @JsonKey(name: 'districtCode')
  String districtCode;

  @JsonKey(name: 'email')
  String email;

  @JsonKey(name: 'essential')
  String essential;

  @JsonKey(name: 'isBind')
  int isBind;

  @JsonKey(name: 'isMemberPrice')
  int isMemberPrice;

  @JsonKey(name: 'monthBissinessTarget')
  int monthBissinessTarget;

  @JsonKey(name: 'openTime')
  String openTime;

  @JsonKey(name: 'parentAll')
  String parentAll;

  @JsonKey(name: 'parentId')
  int parentId;

  @JsonKey(name: 'phone')
  String phone;

  @JsonKey(name: 'province')
  String province;

  @JsonKey(name: 'provinceCode')
  String provinceCode;

  @JsonKey(name: 'storeHeadImage')
  String storeHeadImage;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'storeName')
  String storeName;

  @JsonKey(name: 'storeNo')
  String storeNo;

  @JsonKey(name: 'storeStatus')
  int storeStatus;

  @JsonKey(name: 'storeTypeId')
  int storeTypeId;

  @JsonKey(name: 'storeTypeName')
  String storeTypeName;

  @JsonKey(name: 'tip')
  String tip;

  @JsonKey(name: 'utime')
  String utime;

  @JsonKey(name: 'weekBissinessTarget')
  int weekBissinessTarget;

  @JsonKey(name: 'yearBissinessTarget')
  int yearBissinessTarget;

  Store(
    this.addressDetail,
    this.city,
    this.cityCode,
    this.closeTime,
    this.ctime,
    this.dayBissinessTarget,
    this.district,
    this.districtCode,
    this.email,
    this.essential,
    this.isBind,
    this.isMemberPrice,
    this.monthBissinessTarget,
    this.openTime,
    this.parentAll,
    this.parentId,
    this.phone,
    this.province,
    this.provinceCode,
    this.storeHeadImage,
    this.storeId,
    this.storeName,
    this.storeNo,
    this.storeStatus,
    this.storeTypeId,
    this.storeTypeName,
    this.tip,
    this.utime,
    this.weekBissinessTarget,
    this.yearBissinessTarget,
  );

  factory Store.fromJson(Map<String, dynamic> srcJson) => _$StoreFromJson(srcJson);

  Map<String, dynamic> toJson() => _$StoreToJson(this);
}

@JsonSerializable()
class OrderSurcharge extends Object {
  int id;

  String unionOrderId;

  String surchargeName;

  int surchargeType;

  int surchargeValue;

  int discountEnable;

  int surchargeId;

  int surchargeAmount;

  int surchargeAmountOrg;

  OrderSurcharge(
    this.id,
    this.unionOrderId,
    this.surchargeName,
    this.surchargeType,
    this.surchargeValue,
    this.discountEnable,
    this.surchargeId,
    this.surchargeAmount,
    this.surchargeAmountOrg,
  );

  factory OrderSurcharge.fromJson(Map<String, dynamic> srcJson) => _$OrderSurchargeFromJson(srcJson);

  Map<String, dynamic> toJson() => _$OrderSurchargeToJson(this);
}
